/**
 * 积分相关接口
 *
 */
import request from '@/utils/request'

// 获取积分配置
export function getPointsConfig() {
  return request({
    url: '/memberAdmin/points/rule',
    method: 'get'
  })
}

// 更新积分配置
export function updatePointsConfig(data) {
  return request({
    url: '/memberAdmin/points/rule',
    method: 'put',
    data: data
  })
}

// 获取积分商城配置
export function getPointsMallConfig() {
  return request({
    url: '/mall_admin/config/',
    method: 'get'
  })
}

// 更新积分商城配置
export function updatePointsMallConfig(data) {
  return request({
    url: '/mall_admin/config/update',
    method: 'post',
    data: data
  })
}

// 增加会员积分
export function addVipAccountPoints(data) {
  return request({
    url: '/memberAdmin/memberAccount/giftPoints',
    method: 'post',
    data: data
  })
}

// 减少会员积分
export function reduceVipAccountPoints(data) {
  return request({
    url: '/memberAdmin/memberAccount/consumePoints',
    method: 'post',
    data: data
  })
}

// 添加商品
export function addProduct(data) {
  return request({
    url: '/mall_admin/product/add',
    method: 'post',
    data: data
  })
}

// 更新商品
export function updateProduct(data) {
  return request({
    url: '/mall_admin/product/update',
    method: 'post',
    data: data
  })
}

// 更新商品上下架
export function changeProductState(data) {
  return request({
    url: '/mall_admin/product/change_state',
    method: 'post',
    data: data
  })
}

// 获取后台商品列表
export function getProductList(data) {
  return request({
    url: '/mall_admin/product/list',
    method: 'post',
    data: data
  })
}

// 获取商品详情
export function getProductDetail(params) {
  return request({
    url: '/mall_admin/product/detail',
    method: 'get',
    params: params
  })
}

// 修改总库存
export function modifyTotalStock(data) {
  return request({
    url: '/mall_admin/product/modify_total_stock',
    method: 'post',
    data: data
  })
}

// 修改每日库存
export function modifyDailyStock(data) {
  return request({
    url: '/mall_admin/product/modify_daily_stock',
    method: 'post',
    data: data
  })
}

/**
 * @method modifySort.
 * @description 排序商品
 * @param { Object } productId:商品id，sort:排序值
 */
export function modifySort(params) {
  return request({
    url: '/mall_admin/product/modify_sort',
    method: 'post',
    params: params
  })
}

